package com.chinasoft.book.app;

import com.chinasoft.book.mapper.BookMapper;
import com.chinasoft.book.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class BeanLifeMain {

    public static void main(String[] args) {
        //  bean 的生命周期
        ApplicationContext ioc = new ClassPathXmlApplicationContext("bean_life.xml");
//        ClassPathXmlApplicationContext ioc = new ClassPathXmlApplicationContext("bean_life.xml");

        // 通过bean 构造方法
        BookMapper bookMapper = ioc.getBean("bookMapper", BookMapper.class);

        // ioc 容器销毁, 会销毁容器里面的bean(实例化对象）
        ((ClassPathXmlApplicationContext)ioc).close();


    }
}
